import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:my_app/app/modules/empty/empty_controller.dart';
import 'package:my_app/app/widgets/cell/cell.dart';
import 'package:my_app/app/widgets/empty_widget.dart';

/// empty_page.dart
///
/// Created by fuchuanwei on Tue Apr 11 2023.
///
/// Description: 内容为空页面
///
class EmptyPage extends GetView<EmptyController> {
  const EmptyPage({super.key});

  @override
  Widget build(BuildContext context) {
    Get.put(EmptyController());
    return Scaffold(
      appBar: AppBar(title: Text('内容为空')),
      body: ListView(
        children: [
          _emptyDemo(),
          _modeList(),
        ],
      ),
    );
  }

  Widget _emptyDemo() {
    return SizedBox(
      height: 300.0,
      child: Obx(() => EmptyWidget(
            mode: controller.mode.value,
            child: ElevatedButton(
              onPressed: () => {},
              child: Text('去添加'),
            ),
          )),
    );
  }

  Widget _modeList() {
    return Column(
      children: [
        Cell(
          titleText: "购物车为空",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.car),
        ),
        Cell(
          titleText: "数据为空",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.data),
        ),
        Cell(
          titleText: "没有优惠卷",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.coupon),
        ),
        Cell(
          titleText: "无历史记录",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.history),
        ),
        Cell(
          titleText: "列表为空",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.list),
        ),
        Cell(
          titleText: "消息列表为空",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.message),
        ),
        Cell(
          titleText: "无新闻列表",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.news),
        ),
        Cell(
          titleText: "订单为空",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.order),
        ),
        Cell(
          titleText: "页面不存在",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.page),
        ),
        Cell(
          titleText: "无权限",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.permission),
        ),
        Cell(
          titleText: "没有搜索结果",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.search),
        ),
        Cell(
          titleText: "没有WIFI",
          rightIcon: Icons.arrow_forward_ios,
          onTap: () => controller.changeMode(EmptyMode.wifi),
        )
      ],
    );
  }
}
